package com.atguigu.gmall.task.config;

import com.atguigu.gmall.task.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author: 李旭
 * @create: 2021-07-28 09:55
 *
 *   半夜 0点执行 将秒杀的数据导入缓存中
 **/
@Component
public class Task0 {

    @Autowired
    private RabbitService rabbitService;
    //定时任务 半夜0点
    //@Scheduled(cron = "0 0 0 * * ?")
    @Scheduled(cron = "0/5 * * * * ?")
    public void task0(){
        System.out.println("每5秒执行一次");
        //发消息
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,
                MqConst.ROUTING_TASK_1,"");
    }
}
